Side Length of a Regular n-gon

n-gon.png
Figure 1: n-gon. Here $n=7$. The figure was drawn using Geogebra with the following command: $\text{Sequence}\left((\cos((2k-2)\pi/n),\sin((2k-2)\pi/n)),k,1,n\right)$ which produced the points. The segments were then added to join the points.

I want to derive a side length for a regular n-gon inscribed in a unit circle. So, starting with $n=3$, I assigned the first point to $(1,0)$ and going counter clockwise, let the next 2 points be $$\left(\cos\left(\frac{2\pi}{3}\right),\sin\left(\frac{2\pi}{3}\right)\right)$$ and $$\left(\cos\left(\frac{4\pi}{3}\right),\sin\left(\frac{4\pi}{3}\right)\right)$$ respectively. After a few repetitions of this with other values of $n$, I found that the vertices of this particular n-gon were at $$P_{n}=\left(\cos\left(\frac{(2k-2)\pi}{n}\right), \sin\left(\frac{(2k-2)\pi}{n}\right)\right),\quad k=1,2,...n$$.

To get the side length, I use the distance formula and compute $\left\Vert P_{2}-P_{1}\right\Vert$. That resulted in the following algebra: $$\sqrt{\left[\cos\left(\frac{(2\cdot2-2)\pi}{n}\right)-\cos\left(\frac{(2\cdot1-2)\pi}{n}\right)\right]^{2}+\left[\sin\left(\frac{(2\cdot2-2)\pi}{n}\right)-\sin\left(\frac{(2\cdot1-2)\pi}{n}\right)\right]^{2}}$$ $$\left[\left(\cos\left(2\frac{\pi}{n}\right)-1\right)^{2}+\sin^{2}\left(2\frac{\pi}{n}\right)\right]^{1/2}$$ $$\left[cos^{2}\left(2\frac{\pi}{n}\right)-2\,\cos\left(2\frac{\pi}{n}\right)+1+\sin^{2}\left(2\frac{\pi}{n}\right)\right]^{1/2}$$ $$\text{substitute }1-sin^{2}\left(2\frac{\pi}{n}\right)=cos^{2}\left(2\frac{\pi}{n}\right)$$ $$\left[1-sin^{2}\left(2\frac{\pi}{n}\right)-2\,\cos\left(2\frac{\pi}{n}\right)+1+\sin^{2}\left(2\frac{\pi}{n}\right)\right]^{1/2}$$ $$\text{sidelength}=\left[2-2\cos\left(2\frac{\pi}{n}\right)\right]^{1/2}$$
Now use the identity $\cos(2\theta)=1-2\sin^{2}(\theta)$ to get $$=\left[2-2\left(1-2\sin^{2}\left(\frac{\pi}{n}\right)\right)\right]^{1/2}$$ $$\left[2-2+4\sin^{2}\left(\frac{\pi}{n}\right)\right]^{1/2}$$ $$=\sqrt{4\sin^{2}\left(\frac{\pi}{n}\right)}$$ $$\text{side length}=2\sin\left(\frac{\pi}{n}\right)$$ To get the side length when the radius is different from $1$, we just need $$\text{Side Length}=R\cdot2\sin\left(\frac{\pi}{n}\right)$$